package com.xbts.quartz.task;

import com.xbts.common.core.redis.RedisDelayQueueHandle;
import com.xbts.system.domain.CnBalanceOrder;
import com.xbts.system.enums.PayStatusEnum;
import com.xbts.system.service.ICnBalanceOrderService;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Component;

import java.util.Map;

/**
 * 订单支付超时处理类
 */
@Component
@Slf4j
public class OrderPaymentTimeout implements RedisDelayQueueHandle<Map> {

    @Autowired
    private ICnBalanceOrderService cnBalanceOrderService;

    @Override
    public void execute(Map map) {
        log.info("(收到订单支付超时延迟消息) {}", map);
        CnBalanceOrder cnBalanceOrder = new CnBalanceOrder();
        cnBalanceOrder.setBalanceId(map.getOrDefault("balanceId", "-1").toString());
        cnBalanceOrder.setPayStatus(PayStatusEnum.CANCEL);
        cnBalanceOrderService.updateById(cnBalanceOrder);
    }
}